﻿using System;
using System.IO;
using System.Windows.Forms;
using System.Xml.Linq;
using Styx;
using Styx.Common;

namespace TuanHA_Monk_Special_Edition_Extreme_PvP
{
    public partial class THMonkGUI : Form
    {
        public THMonkGUI()
        {
            InitializeComponent();
        }

        #region Load

        private void THMonkGUI_Load(object sender, EventArgs e)
        {
            if (
                File.Exists(Utilities.AssemblyDirectory +
                            @"\Routines\TuanHAMonkSpecialEdition\TuanHA-Monk-Special-Edition.jpg"))
            {
                pictureBox1.ImageLocation = Utilities.AssemblyDirectory +
                                            @"\Routines\TuanHAMonkSpecialEdition\TuanHA-Monk-Special-Edition.jpg";
            }

            if (File.Exists(Utilities.AssemblyDirectory +
                            @"\Routines\TuanHAMonkSpecialEdition\SpecialThanks.rtf"))
            {
                richTextBox1.LoadFile(Utilities.AssemblyDirectory +
                                      @"\Routines\TuanHAMonkSpecialEdition\SpecialThanks.rtf");
            }

            if (Classname.GetCurrentSpec() == "BrewMaster" && !StyxWoW.Me.Name.Contains("Dust"))
            {
                tabControl1.TabPages.Remove(tabPage4);
                tabControl1.TabPages.Remove(tabPage5);
            }
            else if (Classname.GetCurrentSpec() == "MistWeaver" && !StyxWoW.Me.Name.Contains("Dust"))
            {
                tabControl1.TabPages.Remove(tabPage3);
                tabControl1.TabPages.Remove(tabPage5);
            }
            else if (!StyxWoW.Me.Name.Contains("Dust"))
            {
                tabControl1.TabPages.Remove(tabPage3);
                tabControl1.TabPages.Remove(tabPage4);
            }

            AoEKey.SelectedIndex = THSettings.Instance.AoEKey; 
            AttackOOC.Checked = THSettings.Instance.AttackOOC;
            AutoMove.Checked = THSettings.Instance.AutoMove;
            AutoFace.Checked = THSettings.Instance.AutoFace;
            AutoBuff.Checked = THSettings.Instance.AutoBuff;
            AutoRacial.Checked = THSettings.Instance.AutoRacial;
            AutoTarget.Checked = THSettings.Instance.AutoTarget;
            AvertHarm.Checked = THSettings.Instance.AvertHarm;
            AvertHarmUnit.Value = THSettings.Instance.AvertHarmUnit;
            AvertHarmHP.Value = THSettings.Instance.AvertHarmHP;
            //AttackManaLevel.Checked = THSettings.Instance.AttackOOC; 
            Backward.SelectedIndex = THSettings.Instance.Backward;
            //BlackoutKick.Checked = THSettings.Instance.BlackoutKick; 
            BlackoutKickMist.Checked = THSettings.Instance.BlackoutKickMist;
            BlackoutKickMistMana.Value = THSettings.Instance.BlackoutKickMistMana;
            BlockInputDelay.Value = THSettings.Instance.BlockInputDelay;
            BlockInputFoF.Checked = THSettings.Instance.BlockInputFoF;
            BlockInputFSK.Checked = THSettings.Instance.BlockInputFSK;
            BlockInputRoll.Checked = THSettings.Instance.BlockInputRoll;
            BreathofFire.Checked = THSettings.Instance.BreathofFire;
            BreathofFireUnit.Value = THSettings.Instance.BreathofFireUnit;
            //BurstDelay.Value = THSettings.Instance.BurstDelay; 
            BurstKey.SelectedIndex = THSettings.Instance.BurstKey;
            BurstHP.Value = THSettings.Instance.BurstHP;
            //Burst.Checked = THSettings.Instance.AttackOOC; 
            ChiBrew.Checked = THSettings.Instance.ChiBrew;
            ChiBrewCurrentChi.Value = THSettings.Instance.ChiBrewCurrentChi;
            ChiBurst.Checked = THSettings.Instance.ChiBurst;
            ChiBurstUnit.Value = THSettings.Instance.ChiBurstUnit;
            ChiBurstHP.Value = THSettings.Instance.ChiBurstHP;
            ChiTorpedo.Checked = THSettings.Instance.ChiTorpedo;
            ChiTorpedoHP.Value = THSettings.Instance.ChiTorpedoHP;
            ChiTorpedoMist.Checked = THSettings.Instance.ChiTorpedoMist;
            ChiTorpedoMistUnit.Value = THSettings.Instance.ChiTorpedoMistUnit;
            ChiTorpedoMistHP.Value = THSettings.Instance.ChiTorpedoMistHP;
            ChiWave.Checked = THSettings.Instance.ChiWave;
            ChiWaveHP.Value = THSettings.Instance.ChiWaveHP;
            ChiWaveMe.Checked = THSettings.Instance.ChiWaveMe;
            ChiWaveMeHP.Value = THSettings.Instance.ChiWaveMeHP;
            Clash.Checked = THSettings.Instance.Clash;
            CracklingJadeLightning.Checked = THSettings.Instance.CracklingJadeLightning;
            CracklingJadeLightningHP.Value = THSettings.Instance.CracklingJadeLightningHP;
            CracklingJadeLightningMist.Checked = THSettings.Instance.CracklingJadeLightningMist;
            CracklingJadeLightningMistMana.Value = THSettings.Instance.CracklingJadeLightningMistMana;
            DampenHam.Checked = THSettings.Instance.DampenHam;
            DampenHamHP.Value = THSettings.Instance.DampenHamHP;
            DetoxCC.Checked = THSettings.Instance.DetoxCC;
            DetoxDebuff.Checked = THSettings.Instance.DetoxDebuff;
            DetoxNumberDebuff.Value = THSettings.Instance.DetoxNumberDebuff;
            DiffuseMagic.Checked = THSettings.Instance.DiffuseMagic;
            DiffuseMagicHP.Value = THSettings.Instance.DiffuseMagicHP;
            DiffuseMagicDebuff.Value = THSettings.Instance.DiffuseMagicDebuff;
            Disable.Checked = THSettings.Instance.Disable;
            DisableBrew.Checked = THSettings.Instance.DisableBrew;
            DisableMist.Checked = THSettings.Instance.DisableMist;
            DizzyingHaze.Checked = THSettings.Instance.DizzyingHaze;
            //DoNotHealAbove 
            DropHealingSphereCombat.Checked = THSettings.Instance.DropHealingSphereCombat;
            DropHealingSphereCombatHP.Value = THSettings.Instance.DropHealingSphereCombatHP;
            DropHealingSphereMovingToEnemy.Checked = THSettings.Instance.DropHealingSphereMovingToEnemy;
            ElusiveBrew.Checked = THSettings.Instance.ElusiveBrew;
            ElusiveBrewHP.Value = THSettings.Instance.ElusiveBrewHP;
            ElusiveBrewStack.Checked = THSettings.Instance.ElusiveBrewStack;
            ElusiveBrewStackNumber.Value = THSettings.Instance.ElusiveBrewStackNumber;
            EnergizingBrew.Checked = THSettings.Instance.EnergizingBrew;
            EnergizingBrewPercent.Value = THSettings.Instance.EnergizingBrewPercent;
            EnvelopingMist.Checked = THSettings.Instance.EnvelopingMist;
            EnvelopingMistHP.Value = THSettings.Instance.EnvelopingMistHP;
            ExpelHarm.Checked = THSettings.Instance.ExpelHarm;
            ExpelHarmHP.Value = THSettings.Instance.ExpelHarmHP;
            FortifyingBrew.Checked = THSettings.Instance.FortifyingBrew;
            FortifyingBrewHP.Value = THSettings.Instance.FortifyingBrewHP;
            FlyingSerpentKick.Checked = THSettings.Instance.FlyingSerpentKick;
            FlyingSerpentKickMinDistance.Value = THSettings.Instance.FlyingSerpentKickMinDistance;
            FistsofFury.Checked = THSettings.Instance.FistsofFury;
            FistsofFuryEnergy.Value = THSettings.Instance.FistsofFuryEnergy;
            Forward.SelectedIndex = THSettings.Instance.Forward;
            GrappleWeapon.Checked = THSettings.Instance.GrappleWeapon;
            GrappleWeaponHP.Value = THSettings.Instance.GrappleWeaponHP;
            Guard.Checked = THSettings.Instance.Guard;
            GuardHP.Value = THSettings.Instance.GuardHP;
            HealingSphereMist.Checked = THSettings.Instance.HealingSphereMist;
            HealingSphereMistHP.Value = THSettings.Instance.HealingSphereMistHP;
            HealingSphereMistTank.Checked = THSettings.Instance.HealingSphereMistTank;
            HealingSphereMistTankMs.Value = THSettings.Instance.HealingSphereMistTankMs;
            HealthStone.Checked = THSettings.Instance.HealthStone;
            HealthStoneHP.Value = THSettings.Instance.HealthStoneHP;
            //InputBlockMode 
            InvokeXuen.Checked = THSettings.Instance.InvokeXuen;
            InvokeXuenHP.Value = THSettings.Instance.InvokeXuenHP;
            InvokeXuenBoss.Checked = THSettings.Instance.InvokeXuenBoss;
            InvokeXuenPlayer.Checked = THSettings.Instance.InvokeXuenPlayer;
            InvokeXuenElite.Checked = THSettings.Instance.InvokeXuenElite;
            InvokeXuenAll.Checked = THSettings.Instance.InvokeXuenAll;
            InvokeXuenBurst.Checked = THSettings.Instance.InvokeXuenBurst;
            InvokeXuenTank.Checked = THSettings.Instance.InvokeXuenTank;
            InvokeXuenTankHP.Value = THSettings.Instance.InvokeXuenTankHP;
            //Jab.Checked = THSettings.Instance.HealthStone;
            JabMist.Checked = THSettings.Instance.JabMist;
            JabMistChi.Value = THSettings.Instance.JabMistChi;
            JabMistMana.Value = THSettings.Instance.JabMistMana;
            KegSmash.Checked = THSettings.Instance.KegSmash;
            KegSmashUnit.Value = THSettings.Instance.KegSmashUnit;
            //LagTolerance 
            LeeroftheOxBrew.Checked = THSettings.Instance.LeeroftheOxBrew;
            LegSweepEnemy.Checked = THSettings.Instance.LegSweepEnemy;
            LegSweepEnemyHP.Value = THSettings.Instance.LegSweepEnemyHP;
            LegSweepInterrupt.Checked = THSettings.Instance.LegSweepInterrupt;
            LegSweepInterruptMs.Value = THSettings.Instance.LegSweepInterruptMs;
            LegSweepMe.Checked = THSettings.Instance.LegSweepMe;
            LegSweepMePercent.Value = THSettings.Instance.LegSweepMePercent;
            LifeCocoon.Checked = THSettings.Instance.LifeCocoon;
            LifeCocoonHP.Value = THSettings.Instance.LifeCocoonHP;
            //PathofBlossoms.Checked = THSettings.Instance.PathofBlossoms;
            //PathofBlossomsEnergy.Value = THSettings.Instance.LegSweepMePercent;
            PathofBlossomsMist.Checked = THSettings.Instance.PathofBlossomsMist;
            PathofBlossomsMana.Value = THSettings.Instance.PathofBlossomsMana;
            //Pause 
            ManaTea.Checked = THSettings.Instance.ManaTea;
            ManaTeaMana.Value = THSettings.Instance.ManaTeaMana;
            ParalysisInterrupt.Checked = THSettings.Instance.ParalysisInterrupt;
            ParalysisInterruptMs.Value = THSettings.Instance.ParalysisInterruptMs;
            PauseKey.SelectedIndex = THSettings.Instance.PauseKey;
            //PauseKeyUse 
            PickChiSphere.Checked = THSettings.Instance.PickChiSphere;
            PickChiSphereMaxDistance.Value = THSettings.Instance.PickChiSphereMaxDistance;
            PickHealingSphere.Checked = THSettings.Instance.PickHealingSphere;
            PickHealingSphereMaxDistance.Value = THSettings.Instance.PickHealingSphereMaxDistance;
            Provoke.Checked = THSettings.Instance.Provoke;
            ProvokeMinDistance.Value = THSettings.Instance.ProvokeMinDistance;
            ProvokeBrew.Checked = THSettings.Instance.ProvokeBrew;
            PurifyingBrew.Checked = THSettings.Instance.PurifyingBrew;
            PurifyingBrewLevel.SelectedIndex = THSettings.Instance.PurifyingBrewLevel;
            ProfBuff.SelectedIndex = THSettings.Instance.ProfBuff;
            ProfBuffHP.Value = THSettings.Instance.ProfBuffHP;
            Roll.Checked = THSettings.Instance.Roll;
            RollMinDistance.Value = THSettings.Instance.RollMinDistance;
            RollMaxDistance.Value = THSettings.Instance.RollMaxDistance;
            RollBrew.Checked = THSettings.Instance.RollBrew;
            RollBrewMinDistance.Value = THSettings.Instance.RollBrewMinDistance;
            RollBrewMaxDistance.Value = THSettings.Instance.RollBrewMaxDistance;
            RushingJadeWind.Checked = THSettings.Instance.RushingJadeWind;
            RushingJadeWindNumberUnit.Value = THSettings.Instance.RushingJadeWindNumberUnit;
            RushingJadeWindMist.Checked = THSettings.Instance.RushingJadeWindMist;
            RushingJadeWindMistNumberUnit.Value = THSettings.Instance.RushingJadeWindMistNumberUnit;
            RushingJadeWindMistHP.Value = THSettings.Instance.RushingJadeWindMistHP;
            RushingJadeWindMist.Checked = THSettings.Instance.RushingJadeWindMist;
            RushingJadeWindMistNumberUnit.Value = THSettings.Instance.RushingJadeWindMistNumberUnit;
            ParalysisInterrupt.Checked = THSettings.Instance.ParalysisInterrupt;
            ParalysisInterruptMs.Value = THSettings.Instance.ParalysisInterruptMs;
            ParalysisMeLowHP.Checked = THSettings.Instance.ParalysisMeLowHP;
            ParalysisMeLowHPPercent.Value = THSettings.Instance.ParalysisMeLowHPPercent;
            RenewingMist.Checked = THSettings.Instance.RenewingMist;
            RenewingMistHP.Value = THSettings.Instance.RenewingMistHP;
            RenewingMistMana.Value = THSettings.Instance.RenewingMistMana;
            Revival.Checked = THSettings.Instance.Revival;
            RevivalUnits.Value = THSettings.Instance.RevivalUnits;
            RevivalHP.Value = THSettings.Instance.RevivalHP;
            SoothingMist.Checked = THSettings.Instance.SoothingMist;
            SoothingMistHP.Value = THSettings.Instance.SoothingMistHP;
            SpearHandStrike.Checked = THSettings.Instance.SpearHandStrike;
            SpearHandStrikeMs.Value = THSettings.Instance.SpearHandStrikeMs;
            SpearHandStrikeSilence.Checked = THSettings.Instance.SpearHandStrikeSilence;
            SpearHandStrikeSilenceHP.Value = THSettings.Instance.SpearHandStrikeSilenceHP;
            SpinningCraneKick.Checked = THSettings.Instance.SpinningCraneKick;
            SpinningCraneKickNumberUnit.Value = THSettings.Instance.SpinningCraneKickNumberUnit;
            SpinningCraneKickMist.Checked = THSettings.Instance.SpinningCraneKickMist;
            SpinningCraneKickMistUnits.Value = THSettings.Instance.SpinningCraneKickMistUnits;
            SpinningCraneKickMistHP.Value = THSettings.Instance.SpinningCraneKickMistHP;
            SpinningCraneKickBrew.Checked = THSettings.Instance.SpinningCraneKickBrew;
            SpinningCraneKickBrewNumberUnit.Value = THSettings.Instance.SpinningCraneKickBrewNumberUnit;
            SpinningFireBlossom.Checked = THSettings.Instance.SpinningFireBlossom;
            SpinningFireBlossomMinDistance.Value = THSettings.Instance.SpinningFireBlossomMinDistance;
            SpinningFireBlossomBrew.Checked = THSettings.Instance.SpinningFireBlossom;
            SpinningFireBlossomBrewMinDistance.Value = THSettings.Instance.SpinningFireBlossomMinDistance;
            StartEating.Value = THSettings.Instance.StartEating;
            StrafleLeft.SelectedIndex = THSettings.Instance.StrafleLeft;
            StrafleRight.SelectedIndex = THSettings.Instance.StrafleRight;
            SummonJadeSerpentStatue.Checked = THSettings.Instance.SummonJadeSerpentStatue;
            SummonJadeSerpentStatueDistance.Value = THSettings.Instance.SummonJadeSerpentStatueDistance;
            SummonBlackOxStatue.Checked = THSettings.Instance.SummonBlackOxStatue;
            SummonBlackOxStatueDistance.Value = THSettings.Instance.SummonBlackOxStatueDistance;
            SurgingMist.Checked = THSettings.Instance.SurgingMist;
            SurgingMistHP.Value = THSettings.Instance.SurgingMistHP;
            ThunderFocusTeaSurgingMist.Checked = THSettings.Instance.ThunderFocusTeaSurgingMist;
            ThunderFocusTeaSurgingMistHP.Value = THSettings.Instance.ThunderFocusTeaSurgingMistHP;
            ThunderFocusTeaUplift.Checked = THSettings.Instance.ThunderFocusTeaUplift;
            ThunderFocusTeaUpliftUnits.Value = THSettings.Instance.ThunderFocusTeaUpliftUnits;
            ThunderFocusTeaUpliftHP.Value = THSettings.Instance.ThunderFocusTeaUpliftHP;
            TigereyeBrew.Checked = THSettings.Instance.TigereyeBrew;
            TigereyeBrewStack.Value = THSettings.Instance.TigereyeBrewStack;
            TouchofDeath.Checked = THSettings.Instance.TouchofDeath;
            TouchofDeathrew.Checked = THSettings.Instance.TouchofDeath;
            TouchofKarma.Checked = THSettings.Instance.TouchofKarma;
            TouchofKarmaHP.Value = THSettings.Instance.TouchofKarmaHP;
            TigerPalmMist.Checked = THSettings.Instance.TigerPalmMist;
            TigerPalmMistMana.Value = THSettings.Instance.TigerPalmMistMana;
            TigerPalmMistTigerPower.Checked = THSettings.Instance.TigerPalmMistTigerPower;
            TigerPalmMistVitalMists.Checked = THSettings.Instance.TigerPalmMistVitalMists;
            TigersLust.Checked = THSettings.Instance.TigersLust;
            TigersLustMe.Checked = THSettings.Instance.TigersLustMe;
            TigersLustMelee.Checked = THSettings.Instance.TigersLustMelee;
            TigersLustCaster.Checked = THSettings.Instance.TigersLustCaster;
            TigersLustHealer.Checked = THSettings.Instance.TigersLustHealer;
            Transcendence.Checked = THSettings.Instance.Transcendence;
            TranscendenceHP.Value = THSettings.Instance.TranscendenceHP;
            TranscendenceDistance.Value = THSettings.Instance.TranscendenceDistance;
            Trinket1.SelectedIndex = THSettings.Instance.Trinket1;
            Trinket1HP.Value = THSettings.Instance.Trinket1HP;
            Trinket2.SelectedIndex = THSettings.Instance.Trinket2;
            Trinket2HP.Value = THSettings.Instance.Trinket2HP;
            TurnLeft.SelectedIndex = THSettings.Instance.TurnLeft;
            TurnRight.SelectedIndex = THSettings.Instance.TurnRight;
            Uplift.Checked = THSettings.Instance.Uplift;
            UpliftUnits.Value = THSettings.Instance.UpliftUnits;
            UpliftHP.Value = THSettings.Instance.UpliftHP;
            UseFoodDrink.Checked = THSettings.Instance.UseFoodDrink;
            ZenSphere.Checked = THSettings.Instance.ZenSphere;
            ZenSphereHP.Value = THSettings.Instance.ZenSphereHP;
            ZenSphereDetonate.Checked = THSettings.Instance.ZenSphereDetonate;
            ZenSphereDetonateUnit.Value = THSettings.Instance.ZenSphereDetonateUnit;
            ZenSphereDetonateHP.Value = THSettings.Instance.ZenSphereDetonateHP;
            ZenSphereMe.Checked = THSettings.Instance.ZenSphereMe;
            ZenSphereMeHP.Value = THSettings.Instance.ZenSphereMeHP;
            ZenSphereMe.Checked = THSettings.Instance.ZenSphereMe;
            ZenMed.Checked = THSettings.Instance.ZenMed;
            ZenMedHP.Value = THSettings.Instance.ZenMedHP;
            ZenMedUnit.Value = THSettings.Instance.ZenMedUnit;
        }

        #endregion

        public string LastSavedMode = "";

        private void OK_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("TuanHA Paladin Settings have been saved", "Save");
            THSettings.Instance.LastSavedMode = LastSavedMode;
            THSettings.Instance.LastSavedSpec = Classname.GetCurrentSpec();
            THSettings.Instance.Save();
            Logging.Write("----------------------------------");
            Logging.Write("TuanHA Monk Settings have been saved");
            Close();

            THSettings.Instance.UpdateStatus = true;
        }

        private void Apply_Click(object sender, EventArgs e)
        {
            THSettings.Instance.LastSavedMode = LastSavedMode;
            THSettings.Instance.LastSavedSpec = Classname.GetCurrentSpec();
            THSettings.Instance.Save();
            Logging.Write("TuanHA Monk Settings have been saved");
            THSettings.Instance.UpdateStatus = true;
        }

        private void Dungeon_Click(object sender, EventArgs e)
        {
            if (File.Exists(Utilities.AssemblyDirectory +
                            @"\Routines\TuanHAMonkSpecialEdition\Preset\TuanHA Monk 2.0 Default Dungeon.xml"))
            {
                THSettings.Instance.LoadFromXML(XElement.Load(Utilities.AssemblyDirectory +
                                                              @"\Routines\TuanHAMonkSpecialEdition\Preset\TuanHA Monk 2.0 Default Dungeon.xml"));
                Logging.Write("----------------------------------");
                Logging.Write("Load TuanHA Monk 2.0 Default Dungeon Settings from a file complete");
                Logging.Write("----------------------------------");
                THMonkGUI_Load(null, null);
            }
            else
            {
                Logging.Write("----------------------------------");
                Logging.Write("File not exists: " + Utilities.AssemblyDirectory +
                              @"\Routines\TuanHAMonkSpecialEdition\Preset\TuanHA Monk 2.0 Default Dungeon.xml");
                Logging.Write("Load TuanHA Monk 2.0 Default Dungeon Settings from a file fail.");
                Logging.Write("----------------------------------");
                THMonkGUI_Load(null, null);
            }
        }

        private void Raid_Click(object sender, EventArgs e)
        {
            if (File.Exists(Utilities.AssemblyDirectory +
                            @"\Routines\TuanHAMonkSpecialEdition\Preset\TuanHA Monk 2.0 Default Raid.xml"))
            {
                THSettings.Instance.LoadFromXML(XElement.Load(Utilities.AssemblyDirectory +
                                                              @"\Routines\TuanHAMonkSpecialEdition\Preset\TuanHA Monk 2.0 Default Raid.xml"));
                Logging.Write("----------------------------------");
                Logging.Write("Load TuanHA Monk 2.0 Default Raid Settings from a file complete");
                Logging.Write("----------------------------------");
                THMonkGUI_Load(null, null);
            }
            else
            {
                Logging.Write("----------------------------------");
                Logging.Write("File not exists: " + Utilities.AssemblyDirectory +
                              @"\Routines\TuanHAMonkSpecialEdition\Preset\TuanHA Monk 2.0 Default Raid.xml");
                Logging.Write("Load TuanHA Monk 2.0 Default Raid Settings from a file fail.");
                Logging.Write("----------------------------------");
            }
        }

        private void PvP_Click(object sender, EventArgs e)
        {
            if (File.Exists(Utilities.AssemblyDirectory +
                            @"\Routines\TuanHAMonkSpecialEdition\Preset\TuanHA Monk 2.0 Default PvP.xml"))
            {
                THSettings.Instance.LoadFromXML(XElement.Load(Utilities.AssemblyDirectory +
                                                              @"\Routines\TuanHAMonkSpecialEdition\Preset\TuanHA Monk 2.0 Default PvP.xml"));
                Logging.Write("----------------------------------");
                Logging.Write("Load TuanHA Monk 2.0 Default Raid Settings from a file complete");
                Logging.Write("----------------------------------");
                THMonkGUI_Load(null, null);
            }
            else
            {
                Logging.Write("----------------------------------");
                Logging.Write("File not exists: " + Utilities.AssemblyDirectory +
                              @"\Routines\TuanHAMonkSpecialEdition\Preset\TuanHA Monk 2.0 Default PvP.xml");
                Logging.Write("Load TuanHA Monk 2.0 Default PvP Settings from a file fail.");
                Logging.Write("----------------------------------");
            }
        }

        private void Quest_Click(object sender, EventArgs e)
        {
            if (File.Exists(Utilities.AssemblyDirectory +
                            @"\Routines\TuanHAMonkSpecialEdition\Preset\TuanHA Monk 2.0 Default Quest.xml"))
            {
                THSettings.Instance.LoadFromXML(XElement.Load(Utilities.AssemblyDirectory +
                                                              @"\Routines\TuanHAMonkSpecialEdition\Preset\TuanHA Monk 2.0 Default Quest.xml"));
                Logging.Write("----------------------------------");
                Logging.Write("Load TuanHA Monk 2.0 Default Quest Settings from a file complete");
                Logging.Write("----------------------------------");
                THMonkGUI_Load(null, null);
            }
            else
            {
                Logging.Write("----------------------------------");
                Logging.Write("File not exists: " + Utilities.AssemblyDirectory +
                              @"\Routines\TuanHAMonkSpecialEdition\Preset\TuanHA Monk 2.0 Default Quest.xml");
                Logging.Write("Load TuanHA Monk 2.0 Default Quest Settings from a file fail.");
                Logging.Write("----------------------------------");
            }
        }

        private void AFK_Click(object sender, EventArgs e)
        {
            if (File.Exists(Utilities.AssemblyDirectory +
                            @"\Routines\TuanHAMonkSpecialEdition\Preset\TuanHA Monk 2.0 Default AFK.xml"))
            {
                Logging.Write("----------------------------------");
                THSettings.Instance.LoadFromXML(XElement.Load(Utilities.AssemblyDirectory +
                                                              @"\Routines\TuanHAMonkSpecialEdition\Preset\TuanHA Monk 2.0 Default AFK.xml"));
                Logging.Write("Load TuanHA Monk 2.0 Default AFK Settings from a file complete");
                Logging.Write("----------------------------------");
                THMonkGUI_Load(null, null);
            }
            else
            {
                Logging.Write("----------------------------------");
                Logging.Write("File not exists: " + Utilities.AssemblyDirectory +
                              @"\Routines\TuanHAMonkSpecialEdition\Preset\TuanHA Monk 2.0 Default AFK.xml");
                Logging.Write("Load TuanHA Monk 2.0 Default AFK Settings from a file fail.");
                Logging.Write("----------------------------------");
            }
        }

        private void LoadSetting_Click(object sender, EventArgs e)
        {
            var openFileDialog = new OpenFileDialog {Filter = "Setting File|*.xml", Title = "Load Setting from a File"};
            openFileDialog.ShowDialog();

            //if (DialogResult != DialogResult.OK)
            //{
            //    Logging.Write(DialogResult.ToString());
            //    return;
            //}

            if (openFileDialog.FileName.Contains(".xml"))
            {
                Logging.Write(DialogResult.ToString());
                THSettings.Instance.LoadFromXML(XElement.Load(openFileDialog.FileName));
                Logging.Write("----------------------------------");
                Logging.Write("Load Setting from: " + openFileDialog.FileName);
                Logging.Write("----------------------------------");
                THMonkGUI_Load(null, null);
            }
            else
            {
                return;
            }
        }

        private void SaveSetting_Click(object sender, EventArgs e)
        {
            var saveFileDialog = new SaveFileDialog();
            saveFileDialog.Filter = "Setting File|*.xml";
            saveFileDialog.Title = "Save Setting to a File";
            saveFileDialog.DefaultExt = "xml";
            saveFileDialog.FileName = "TuanHA Monk 2.0 " + Classname.CurrentSpec;

            saveFileDialog.ShowDialog();

            //if (DialogResult != DialogResult.Abort &&
            //    DialogResult != DialogResult.Ignore &&
            //    DialogResult != DialogResult.No &&
            //    DialogResult != DialogResult.None &&
            //    DialogResult != DialogResult.Retry &&
            //    DialogResult != DialogResult.Cancel)
            //{
            //    Logging.Write(DialogResult.ToString());
            //    return;
            //}

            if (saveFileDialog.FileName.Contains(".xml"))
            {
                Logging.Write(DialogResult.ToString());
                THSettings.Instance.SaveToFile(saveFileDialog.FileName);
                Logging.Write("----------------------------------");
                Logging.Write("Save Setting to: " + saveFileDialog.FileName);
                Logging.Write("----------------------------------");
            }
            else
            {
                return;
            }
        }


        private void CracklingJadeLightning_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.CracklingJadeLightning = CracklingJadeLightning.Checked;
        }

        private void SpearHandStrike_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SpearHandStrike = SpearHandStrike.Checked;
        }

        private void SpearHandStrikeMs_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SpearHandStrikeMs = (int) SpearHandStrikeMs.Value;
        }

        private void SpearHandStrikeSilence_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SpearHandStrikeSilence = SpearHandStrikeSilence.Checked;
        }

        private void SpearHandStrikeSilenceHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SpearHandStrikeSilenceHP = (int) SpearHandStrikeSilenceHP.Value;
        }

        private void BurstKey_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (var i = 0; i <= 46; i++)
            {
                if (BurstKey.SelectedIndex == i)
                {
                    THSettings.Instance.BurstKey = i;
                }
            }
        }

        private void BurstHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.BurstHP = (int) BurstHP.Value;
        }

        private void ProfBuff_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (var i = 0; i <= 8; i++)
            {
                if (ProfBuff.SelectedIndex == i)
                {
                    THSettings.Instance.ProfBuff = i;
                }
            }
        }

        private void ProfBuffHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ProfBuffHP = (int) ProfBuffHP.Value;
        }

        private void Trinket1_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (var i = 0; i <= 8; i++)
            {
                if (Trinket1.SelectedIndex == i)
                {
                    THSettings.Instance.Trinket1 = i;
                }
            }
        }

        private void Trinket1HP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.Trinket1HP = (int) Trinket1HP.Value;
        }

        private void Trinket2_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (var i = 0; i <= 8; i++)
            {
                if (Trinket2.SelectedIndex == i)
                {
                    THSettings.Instance.Trinket2 = i;
                }
            }
        }

        private void Trinket2HP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.Trinket2HP = (int) Trinket2HP.Value;
        }

        private void PickChiSphere_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.PickChiSphere = PickChiSphere.Checked;
        }

        private void PickChiSphereMaxDistance_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.PickChiSphereMaxDistance = (int) PickChiSphereMaxDistance.Value;
        }

        private void PickHealingSphere_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.PickHealingSphere = PickHealingSphere.Checked;
        }

        private void PickHealingSphereMaxDistance_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.PickHealingSphereMaxDistance = (int) PickHealingSphereMaxDistance.Value;
        }

        private void GrappleWeapon_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.GrappleWeapon = GrappleWeapon.Checked;
        }

        private void GrappleWeaponHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.GrappleWeaponHP = (int) GrappleWeaponHP.Value;
        }

        private void FortifyingBrew_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.FortifyingBrew = FortifyingBrew.Checked;
        }

        private void FortifyingBrewHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.FortifyingBrewHP = (int) FortifyingBrewHP.Value;
        }

        private void HealthStone_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.HealthStone = HealthStone.Checked;
        }

        private void HealthStoneHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.HealthStoneHP = (int) HealthStoneHP.Value;
        }

        private void AttackOOC_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.AttackOOC = AttackOOC.Checked;
        }

        private void AutoBuff_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.AutoBuff = AutoBuff.Checked;
        }

        private void AutoFace_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.AutoFace = AutoFace.Checked;
        }

        private void AutoMove_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.AutoMove = AutoMove.Checked;
        }

        private void AutoRacial_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.AutoRacial = AutoRacial.Checked;
        }

        private void AutoTarget_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.AutoTarget = AutoTarget.Checked;
        }

        private void UseFoodDrink_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.UseFoodDrink = UseFoodDrink.Checked;
        }

        private void StartEating_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.StartEating = (int) StartEating.Value;
        }

        private void PauseKey_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (var i = 0; i <= 40; i++)
            {
                if (PauseKey.SelectedIndex == i)
                {
                    THSettings.Instance.PauseKey = i;
                }
            }
        }

        private void StrafleLeft_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (var i = 0; i <= 40; i++)
            {
                if (StrafleLeft.SelectedIndex == i)
                {
                    THSettings.Instance.StrafleLeft = i;
                }
            }
        }

        private void Forward_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (var i = 0; i <= 40; i++)
            {
                if (Forward.SelectedIndex == i)
                {
                    THSettings.Instance.Forward = i;
                }
            }
        }

        private void StrafleRight_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (var i = 0; i <= 40; i++)
            {
                if (StrafleRight.SelectedIndex == i)
                {
                    THSettings.Instance.StrafleRight = i;
                }
            }
        }

        private void TurnLeft_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (var i = 0; i <= 40; i++)
            {
                if (TurnLeft.SelectedIndex == i)
                {
                    THSettings.Instance.TurnLeft = i;
                }
            }
        }

        private void Backward_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (var i = 0; i <= 40; i++)
            {
                if (Backward.SelectedIndex == i)
                {
                    THSettings.Instance.Backward = i;
                }
            }
        }

        private void TurnRight_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (var i = 0; i <= 40; i++)
            {
                if (TurnRight.SelectedIndex == i)
                {
                    THSettings.Instance.TurnRight = i;
                }
            }
        }

        private void TigersLust_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.TigersLust = TigersLust.Checked;
        }

        private void TigersLustMe_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.TigersLustMe = TigersLustMe.Checked;
        }

        private void TigersLustMelee_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.TigersLustMelee = TigersLustMelee.Checked;
        }

        private void TigersLustCaster_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.TigersLustCaster = TigersLustCaster.Checked;
        }

        private void TigersLustHealer_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.TigersLustHealer = TigersLustHealer.Checked;
        }

        private void ChiWaveMe_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ChiWaveMe = ChiWaveMe.Checked;
        }

        private void ChiWaveMeHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ChiWaveMeHP = (int) ChiWaveMeHP.Value;
        }

        private void ChiWave_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ChiWave = ChiWave.Checked;
        }

        private void ChiWaveHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ChiWaveHP = (int) ChiWaveHP.Value;
        }

        private void ZenSphereMe_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ZenSphereMe = ZenSphereMe.Checked;
        }

        private void ZenSphereMeHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ZenSphereMeHP = (int) ZenSphereMeHP.Value;
        }

        private void ZenSphere_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ZenSphere = ZenSphere.Checked;
        }

        private void ZenSphereHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ZenSphereHP = (int) ZenSphereHP.Value;
        }

        private void ZenSphereDetonate_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ZenSphereDetonate = ZenSphereDetonate.Checked;
        }

        private void ZenSphereDetonateUnit_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ZenSphereDetonateUnit = (int) ZenSphereDetonateUnit.Value;
        }

        private void ZenSphereDetonateHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ZenSphereDetonateHP = (int) ZenSphereDetonateHP.Value;
        }

        private void ChiBurst_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ChiBurst = ChiBurst.Checked;
        }

        private void ChiBurstUnit_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ChiBurstUnit = (int) ChiBurstUnit.Value;
        }

        private void ChiBurstHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ChiBurstHP = (int) ChiBurstHP.Value;
        }

        private void ChiBrew_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ChiBrew = ChiBrew.Checked;
        }

        private void ChiBrewCurrentChi_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ChiBrewCurrentChi = (int) ChiBrewCurrentChi.Value;
        }

        private void LegSweepEnemy_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.LegSweepEnemy = LegSweepEnemy.Checked;
        }

        private void LegSweepEnemyHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.LegSweepEnemyHP = (int) LegSweepEnemyHP.Value;
        }

        private void LegSweepMe_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.LegSweepMe = LegSweepMe.Checked;
        }

        private void LegSweepMePercent_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.LegSweepMePercent = (int) LegSweepMePercent.Value;
        }

        private void LegSweepInterrupt_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.LegSweepInterrupt = LegSweepInterrupt.Checked;
        }

        private void LegSweepInterruptMs_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.LegSweepInterruptMs = (int) LegSweepInterruptMs.Value;
        }

        private void DampenHam_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.DampenHam = DampenHam.Checked;
        }

        private void DampenHamHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.DampenHamHP = (int) DampenHamHP.Value;
        }

        private void DiffuseMagic_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.DiffuseMagic = DiffuseMagic.Checked;
        }

        private void DiffuseMagicHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.DiffuseMagicHP = (int) DiffuseMagicHP.Value;
        }

        private void DiffuseMagicDebuff_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.DiffuseMagicDebuff = (int) DiffuseMagicDebuff.Value;
        }

        private void RushingJadeWind_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.RushingJadeWind = RushingJadeWind.Checked;
        }

        private void RushingJadeWindNumberUnit_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.RushingJadeWindNumberUnit = (int) RushingJadeWindNumberUnit.Value;
        }

        private void RushingJadeWindMist_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.RushingJadeWindMist = RushingJadeWindMist.Checked;
        }

        private void RushingJadeWindMistNumberUnit_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.RushingJadeWindMistNumberUnit = (int) RushingJadeWindMistNumberUnit.Value;
        }

        private void RushingJadeWindMistHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.RushingJadeWindMistHP = (int) RushingJadeWindMistHP.Value;
        }

        private void InvokeXuen_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.InvokeXuen = InvokeXuen.Checked;
        }

        private void InvokeXuenHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.InvokeXuenHP = (int) InvokeXuenHP.Value;
        }

        private void InvokeXuenBurst_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.InvokeXuenBurst = InvokeXuenBurst.Checked;
        }

        private void InvokeXuenTank_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.InvokeXuenTank = InvokeXuenTank.Checked;
        }

        private void InvokeXuenTankHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.InvokeXuenTankHP = (int) InvokeXuenTankHP.Value;
        }

        private void ChiTorpedo_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ChiTorpedo = ChiTorpedo.Checked;
        }

        private void ChiTorpedoHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ChiTorpedoHP = (int) ChiTorpedoHP.Value;
        }

        private void ChiTorpedoMist_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ChiTorpedoMist = ChiTorpedoMist.Checked;
        }

        private void ChiTorpedoMistUnit_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ChiTorpedoMistUnit = (int) ChiTorpedoMistUnit.Value;
        }

        private void ChiTorpedoMistHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ChiTorpedoMistHP = (int) ChiTorpedoMistHP.Value;
        }

        private void Provoke_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.Provoke = Provoke.Checked;
        }

        private void ProvokeMinDistance_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ProvokeMinDistance = (int) ProvokeMinDistance.Value;
        }

        private void Disable_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.Disable = Disable.Checked;
        }

        private void EnergizingBrew_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.EnergizingBrew = EnergizingBrew.Checked;
        }

        private void EnergizingBrewPercent_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.EnergizingBrewPercent = (int) EnergizingBrewPercent.Value;
        }

        private void FlyingSerpentKick_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.FlyingSerpentKick = FlyingSerpentKick.Checked;
        }

        private void FlyingSerpentKickMinDistance_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.FlyingSerpentKickMinDistance = (int) FlyingSerpentKickMinDistance.Value;
        }

        private void FistsofFury_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.FistsofFury = FistsofFury.Checked;
        }

        private void FistsofFuryEnergy_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.FistsofFuryEnergy = (int) FistsofFuryEnergy.Value;
        }

        private void Roll_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.Roll = Roll.Checked;
        }

        private void RollMinDistance_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.RollMinDistance = (int) RollMinDistance.Value;
        }

        private void RollMaxDistance_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.RollMaxDistance = (int) RollMaxDistance.Value;
        }

        private void TigereyeBrew_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.TigereyeBrew = TigereyeBrew.Checked;
        }

        private void TigereyeBrewStack_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.TigereyeBrewStack = (int) TigereyeBrewStack.Value;
        }

        private void TouchofDeath_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.TouchofDeath = TouchofDeath.Checked;
        }

        private void TouchofKarma_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.TouchofKarma = TouchofKarma.Checked;
        }

        private void TouchofKarmaHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.TouchofKarmaHP = (int) TouchofKarmaHP.Value;
        }

        private void SpinningCraneKick_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SpinningCraneKick = SpinningCraneKick.Checked;
        }

        private void SpinningCraneKickNumberUnit_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SpinningCraneKickNumberUnit = (int) SpinningCraneKickNumberUnit.Value;
        }

        private void SpinningFireBlossom_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SpinningFireBlossom = SpinningFireBlossom.Checked;
        }

        private void SpinningFireBlossomMinDistance_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SpinningFireBlossomMinDistance = (int) SpinningFireBlossomMinDistance.Value;
        }

        private void BlockInputDelay_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.BlockInputDelay = (int) BlockInputDelay.Value;
        }

        private void BlockInputFoF_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.BlockInputFoF = BlockInputFoF.Checked;
        }

        private void BlockInputFSK_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.BlockInputFSK = BlockInputFSK.Checked;
        }

        private void BlockInputRoll_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.BlockInputRoll = BlockInputRoll.Checked;
        }

        private void DropHealingSphereCombat_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.DropHealingSphereCombat = DropHealingSphereCombat.Checked;
        }

        private void DropHealingSphereCombatHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.DropHealingSphereCombatHP = (int) DropHealingSphereCombatHP.Value;
        }

        private void DropHealingSphereMovingToEnemy_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.DropHealingSphereMovingToEnemy = DropHealingSphereMovingToEnemy.Checked;
        }

        private void ParalysisInterrupt_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ParalysisInterrupt = ParalysisInterrupt.Checked;
        }

        private void ParalysisInterruptMs_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ParalysisInterruptMs = (int) ParalysisInterruptMs.Value;
        }

        private void ParalysisMeLowHP_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ParalysisMeLowHP = ParalysisMeLowHP.Checked;
        }

        private void ParalysisMeLowHPPercent_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ParalysisMeLowHPPercent = (int) ParalysisMeLowHPPercent.Value;
        }

        private void Transcendence_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.Transcendence = Transcendence.Checked;
        }

        private void TranscendenceHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.TranscendenceHP = (int) TranscendenceHP.Value;
        }

        private void TranscendenceDistance_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.TranscendenceDistance = (int) TranscendenceDistance.Value;
        }

        private void InvokeXuenBoss_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.InvokeXuenBoss = InvokeXuenBoss.Checked;
        }

        private void InvokeXuenPlayer_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.InvokeXuenPlayer = InvokeXuenPlayer.Checked;
        }

        private void InvokeXuenElite_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.InvokeXuenElite = InvokeXuenElite.Checked;
        }

        private void InvokeXuenAll_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.InvokeXuenAll = InvokeXuenAll.Checked;
        }

        private void ExpelHarm_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ExpelHarm = ExpelHarm.Checked;
        }

        private void ExpelHarmHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ExpelHarmHP = (int) ExpelHarmHP.Value;
        }

        private void BlackoutKickMist_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.BlackoutKickMist = BlackoutKickMist.Checked;
        }

        private void CracklingJadeLightningMist_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.CracklingJadeLightningMist = CracklingJadeLightningMist.Checked;
        }

        private void EnvelopingMist_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.EnvelopingMist = EnvelopingMist.Checked;
        }

        private void EnvelopingMistHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.EnvelopingMistHP = (int) EnvelopingMistHP.Value;
        }

        private void HealingSphereMist_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.HealingSphereMist = HealingSphereMist.Checked;
        }

        private void HealingSphereMistHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.HealingSphereMistHP = (int) HealingSphereMistHP.Value;
        }

        private void HealingSphereMistTank_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.HealingSphereMistTank = HealingSphereMistTank.Checked;
        }

        private void JabMist_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.JabMist = JabMist.Checked;
        }

        private void JabMistChi_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.JabMistChi = (int) JabMistChi.Value;
        }

        private void LifeCocoon_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.LifeCocoon = LifeCocoon.Checked;
        }

        private void LifeCocoonHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.LifeCocoonHP = (int) LifeCocoonHP.Value;
        }

        private void RenewingMist_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.RenewingMist = RenewingMist.Checked;
        }

        private void RenewingMistHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.RenewingMistHP = (int) RenewingMistHP.Value;
        }

        private void Revival_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.Revival = Revival.Checked;
        }

        private void RevivalUnits_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.RevivalUnits = (int) RevivalUnits.Value;
        }

        private void RevivalHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.RevivalHP = (int) RevivalHP.Value;
        }

        private void SoothingMist_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SoothingMist = SoothingMist.Checked;
        }

        private void SoothingMistHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SoothingMistHP = (int) SoothingMistHP.Value;
        }

        private void SpinningCraneKickMist_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SpinningCraneKickMist = SpinningCraneKickMist.Checked;
        }

        private void SpinningCraneKickMistUnits_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SpinningCraneKickMistUnits = (int) SpinningCraneKickMistUnits.Value;
        }

        private void SpinningCraneKickMistHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SpinningCraneKickMistHP = (int) SpinningCraneKickMistHP.Value;
        }

        private void SummonJadeSerpentStatue_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SummonJadeSerpentStatue = SummonJadeSerpentStatue.Checked;
        }

        private void SurgingMist_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SurgingMist = SurgingMist.Checked;
        }

        private void SurgingMistHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SurgingMistHP = (int) SurgingMistHP.Value;
        }

        private void ThunderFocusTeaSurgingMist_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ThunderFocusTeaSurgingMist = ThunderFocusTeaSurgingMist.Checked;
        }

        private void ThunderFocusTeaSurgingMistHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ThunderFocusTeaSurgingMistHP = (int) ThunderFocusTeaSurgingMistHP.Value;
        }

        private void ThunderFocusTeaUplift_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ThunderFocusTeaUplift = ThunderFocusTeaUplift.Checked;
        }

        private void ThunderFocusTeaUpliftUnits_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ThunderFocusTeaUpliftUnits = (int) ThunderFocusTeaUpliftUnits.Value;
        }

        private void ThunderFocusTeaUpliftHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ThunderFocusTeaUpliftHP = (int) ThunderFocusTeaUpliftHP.Value;
        }

        private void TigerPalmMist_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.TigerPalmMist = TigerPalmMist.Checked;
        }

        private void Uplift_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.Uplift = Uplift.Checked;
        }

        private void UpliftUnits_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.UpliftUnits = (int) UpliftUnits.Value;
        }

        private void UpliftHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.UpliftHP = (int) UpliftHP.Value;
        }

        private void ManaTea_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ManaTea = ManaTea.Checked;
        }

        private void ManaTeaMana_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ManaTeaMana = (int) ManaTeaMana.Value;
        }

        private void BlackoutKickMistMana_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.BlackoutKickMistMana = (int) BlackoutKickMistMana.Value;
        }

        private void JabMistMana_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.JabMistMana = (int) JabMistMana.Value;
        }

        private void RenewingMistMana_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.RenewingMistMana = (int) RenewingMistMana.Value;
        }

        private void TigerPalmMistMana_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.TigerPalmMistMana = (int) TigerPalmMistMana.Value;
        }

        private void TigerPalmMistTigerPower_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.TigerPalmMistTigerPower = TigerPalmMistTigerPower.Checked;
        }

        private void TigerPalmMistVitalMists_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.TigerPalmMistVitalMists = TigerPalmMistVitalMists.Checked;
        }

        private void AvertHarm_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.AvertHarm = AvertHarm.Checked;
        }

        private void AvertHarmUnit_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.AvertHarmUnit = (int) AvertHarmUnit.Value;
        }

        private void AvertHarmHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.AvertHarmHP = (int) AvertHarmHP.Value;
        }

        private void BreathofFire_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.BreathofFire = BreathofFire.Checked;
        }

        private void BreathofFireUnit_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.BreathofFireUnit = (int) BreathofFireUnit.Value;
        }

        private void Clash_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.Clash = Clash.Checked;
        }

        private void DisableBrew_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.DisableBrew = DisableBrew.Checked;
        }

        private void DizzyingHaze_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.DizzyingHaze = DizzyingHaze.Checked;
        }

        private void Guard_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.Guard = Guard.Checked;
        }

        private void KegSmash_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.KegSmash = KegSmash.Checked;
        }

        private void KegSmashUnit_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.KegSmashUnit = (int) KegSmashUnit.Value;
        }

        private void ProvokeBrew_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ProvokeBrew = ProvokeBrew.Checked;
        }

        private void PurifyingBrew_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.PurifyingBrew = PurifyingBrew.Checked;
        }

        private void PurifyingBrewLevel_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (var i = 0; i <= 3; i++)
            {
                if (PauseKey.SelectedIndex == i)
                {
                    THSettings.Instance.PauseKey = i;
                }
            }
        }

        private void SpinningCraneKickBrew_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SpinningCraneKickBrew = SpinningCraneKickBrew.Checked;
        }

        private void SpinningCraneKickBrewNumberUnit_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SpinningCraneKickBrewNumberUnit = (int) SpinningCraneKickBrewNumberUnit.Value;
        }

        private void SpinningFireBlossomBrew_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SpinningFireBlossom = SpinningFireBlossomBrew.Checked;
        }

        private void SpinningFireBlossomBrewMinDistance_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SpinningFireBlossomMinDistance = (int) SpinningFireBlossomBrewMinDistance.Value;
        }

        private void SummonBlackOxStatue_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SummonBlackOxStatue = SummonBlackOxStatue.Checked;
        }

        private void TouchofDeathrew_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.TouchofDeath = TouchofDeathrew.Checked;
        }

        private void SummonJadeSerpentStatueDistance_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SummonJadeSerpentStatueDistance = (int) SummonJadeSerpentStatueDistance.Value;
        }

        private void SummonBlackOxStatueDistance_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.SummonBlackOxStatueDistance = (int) SummonBlackOxStatueDistance.Value;
        }

        private void LeeroftheOxBrew_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.LeeroftheOxBrew = LeeroftheOxBrew.Checked;
        }

        private void CracklingJadeLightningMistMana_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.CracklingJadeLightningMistMana = (int) CracklingJadeLightningMistMana.Value;
        }

        private void DisableMist_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.DisableMist = DisableMist.Checked;
        }

        private void DetoxCC_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.DetoxCC = DetoxCC.Checked;
        }

        private void DetoxNumberDebuff_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.DetoxNumberDebuff = (int) DetoxNumberDebuff.Value;
        }

        private void DetoxDebuff_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.DetoxDebuff = DetoxDebuff.Checked;
        }

        private void CracklingJadeLightningHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.CracklingJadeLightningHP = (int) CracklingJadeLightningHP.Value;
        }

        private void GuardHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.GuardHP = (int) GuardHP.Value;
        }

        private void ElusiveBrew_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ElusiveBrew = ElusiveBrew.Checked;
        }

        private void ElusiveBrewHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ElusiveBrewHP = (int) ElusiveBrewHP.Value;
        }

        private void ZenMed_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ZenMed = ZenMed.Checked;
        }

        private void ZenMedUnit_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ZenMedUnit = (int) ZenMedUnit.Value;
        }

        private void ZenMedHP_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ZenMedHP = (int) ZenMedHP.Value;
        }

        private void PathofBlossomsMist_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.PathofBlossomsMist = PathofBlossomsMist.Checked;
        }

        private void PathofBlossomsMana_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.PathofBlossomsMana = (int) PathofBlossomsMana.Value;
        }

        private void RollBrew_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.RollBrew = RollBrew.Checked;
        }

        private void RollBrewMinDistance_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.RollBrewMinDistance = (int) RollBrewMinDistance.Value;
        }

        private void RollBrewMaxDistance_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.RollBrewMaxDistance = (int) RollBrewMaxDistance.Value;
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("http://tuanha2000vn.wordpress.com/");
        }

        private void HealingSphereMistTankMs_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.HealingSphereMistTankMs = (int)HealingSphereMistTankMs.Value;
        }

        private void ElusiveBrewStack_CheckedChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ElusiveBrewStack = ElusiveBrewStack.Checked;
        }

        private void ElusiveBrewStackNumber_ValueChanged(object sender, EventArgs e)
        {
            THSettings.Instance.ElusiveBrewStackNumber = (int)ElusiveBrewStackNumber.Value;
        }

        private void AoEKey_SelectedIndexChanged(object sender, EventArgs e)
        {
            for (var i = 0; i <= 40; i++)
            {
                if (AoEKey.SelectedIndex == i)
                {
                    THSettings.Instance.AoEKey = i;
                }
            }
        }
    }
}